package ar.edu.uade.fain.ad.test.client.delegate;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.List;

import ar.edu.uade.fain.ad.test.common.dto.ContratoDTO;
import ar.edu.uade.fain.ad.test.common.dto.CoordinadorDTO;
import ar.edu.uade.fain.ad.test.common.remote.SistemaService;

public class SistemaServiceDelegateBean implements SistemaServiceDelegate {

	private SistemaService service;

	public SistemaServiceDelegateBean() {
		super();
		try {
			setService((SistemaService)
					Naming.lookup("//localhost:1099/sistema"));
		} catch (MalformedURLException e) {
			throw new IllegalStateException(e);
		} catch (RemoteException e) {
			throw new IllegalStateException(e);
		} catch (NotBoundException e) {
			throw new IllegalStateException(e);
		}
	}

	public SistemaService getService() {
		return service;
	}

	public void setService(SistemaService service) {
		this.service = service;
	}

	@Override
	public ContratoDTO getContratoDeDesarrolladorConMayorConvenio() {
		try {
			return getService().getContratoDeDesarrolladorConMayorConvenio();
		} catch (RemoteException e) {
			throw new RuntimeException(e);
		}
	}

	@Override
	public List<CoordinadorDTO> getCoordinadorasEnImplementacionYControl() {
		try {
			return getService().getCoordinadorasEnImplementacionYControl();
		} catch (RemoteException e) {
			throw new RuntimeException(e);
		}
	}

}
